import Home from '@/views/Home'
import Search from '@/views/Search'
import NotFound from '@/views/NotFound'
import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter) // VueRouter插件初始化

// 创建了一个路由对象
const router = new VueRouter({
  //注意：一旦采用了history模式，地址栏就没有#，需要后台配置规则
  mode: 'history',
  /*   //1.静态传参
    routes: [
      { path: '/home', component: Home },
      { path: '/search', component: Search }
    ], */
  //2.动态传参
  /*   routes: [
      { path: '/home', component: Home },
      { path: '/search/:words', component: Search }
    ], */
  //3.动态路由可选符
  routes: [
    //Vue路由的重定向
    { path: '/', redirect: '/home' },
    { path: '/home', component: Home },
    { name: 'search', path: '/search/:words?', component: Search },
    { path: '*', component: NotFound }
  ]
})

export default router